import 'package:flutter/material.dart';
import 'package:upgrader/upgrader.dart';

class UpdateService {
  static void configureUpgrader() {
    final upgrader = Upgrader(
      debugLogging: true,
      durationUntilAlertAgain: const Duration(days: 3),
    );

    upgrader.willDisplayUpgrade = (
        {required bool display,
        String? installedVersion,
        UpgraderVersionInfo? versionInfo}) {
      debugPrint('Will display upgrade dialog: $display');
    };
  }
}

/* 
  可以结合go_router
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Enterprise App',
      home: UpgradeAlert(
        upgrader: Upgrader(
          debugLogging: true, // 打开调试日志
          messages: CustomUpgraderMessages(), // 自定义消息
          durationUntilAlertAgain: const Duration(days: 3), // 提醒间隔
          shouldPopScope: () => true, // 是否允许关闭弹窗
        ),
        child: const HomeScreen(),
      ),
    );
  }
}
 */